# -*- coding:utf-8 -*-
import sys  
reload(sys)  
sys.setdefaultencoding('utf8')

#from __future__ import unicode_literals
import datetime

from django.db import models
from django.utils import timezone
from django.utils.encoding import python_2_unicode_compatible


class Vehicle(models.Model):
    Vehicle_text = models.CharField(max_length=200)
    #pub_date = models.DateTimeField('date published')


    class Meta:
        verbose_name='设备'
        verbose_name_plural='设备'

    def __str__(self):
        return self.Vehicle_text
    #def was_published_recently(self):
    #    now = timezone.now()
    #    return now - datetime.timedelta(days=1) <= self.pub_date <= now
    #was_published_recently.admin_order_field = 'pub_date'
    #was_published_recently.boolean = True
    #was_published_recently.short_description = 'Published recently?'

class Trip(models.Model):
    Vehicle = models.ForeignKey(Vehicle, on_delete=models.CASCADE)
    Trip_text = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')

    class Meta:
        verbose_name='行程'
        verbose_name_plural='行程'
    def __str__(self):
        return self.Trip_text



class Trace(models.Model):
    Trip = models.ForeignKey(Trip, on_delete=models.CASCADE)
    Trace_data = models.IntegerField(default=0)

    class Meta:
        verbose_name='轨迹'
        verbose_name_plural='轨迹'

    def __str__(self):
        return str(self.Trace_data)
